package com.service.impl;

import com.dao.ServiceMerchantDao;
import com.dao.ServiceOrderDao;
import com.pojo.ServiceOrder;
import com.service.ServiceOrderService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class ServiceOrderServiceImpl implements ServiceOrderService {
    @Resource
    private ServiceOrderDao serviceOrderDao;

    @Override
    public boolean add(ServiceOrder serviceOrder) {
        //获取时间
        Date d = new Date();
        long time = d.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        //订单编号
        String orderno = ""+time;
        serviceOrder.setOrderno(orderno);
        //设置日期
        String ordertime = sdf.format(d);
        System.out.println(d);
        serviceOrder.setOrdertime(ordertime);
        serviceOrder.setAppointmentTime((sdf.format(serviceOrder.getAppointmentdate())));
//        serviceOrder.setAppointmentTime(sdf.format(serviceOrder.getAppointmentTime()));

        int result=serviceOrderDao.add(serviceOrder);
        return result>0? true:false;
    }

    @Override
    public List<ServiceOrder> findAll(String username) {

        return serviceOrderDao.findAll(username);
    }

    @Override
    public boolean updateById(Integer id) {
        int count=serviceOrderDao.updateById(id);
        return count>0? true:false;
    }

    @Override
    public boolean delById(Integer id) {
        int count=serviceOrderDao.delById(id);
        return count>0? true:false;
    }


}
